package com.sjb.cp.manager.auth;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author:sjb
 * @CreateTime:2025-02-17
 * @Description: 基于注解的ThreadLocal的校验
 * @Version：1.0
 */
public class SaTokenContextHolder {

    private static final ThreadLocal<Map<String,Object>> CONTEXT_HOLDER = ThreadLocal.withInitial(HashMap::new);

    /**
     * 设置上下文数据
     * @param key
     * @param value
     */
    public static void set(String key,Object value){
        CONTEXT_HOLDER.get().put(key, value);
    }

    /**
     * 获取上下文数据
     * @param key
     * @return
     */
    public static Object get(String key){
        return CONTEXT_HOLDER.get().get(key);
    }

    /**
     * 清理上下文数据
     */
    public static void remove(){
         CONTEXT_HOLDER.remove();
    }


}
